package com.example.financechain.schedule;

import com.alibaba.fastjson.JSON;
//import com.example.financechain.Utils.QueryBlockHeightAndLatestBlock;
import com.example.financechain.config.CacheKeyManager;
import com.example.financechain.domain.BlockInfomation;
import com.example.financechain.domain.entity.Blockexplore;
import com.example.financechain.service.IBlockService;
import com.example.financechain.service.IBlockexploreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
@Slf4j
public class UpdateRedisblock {

    @Scheduled(fixedRate = 1000*60*30) //
    public void test(){
        log.info("定时查询首页展示的区块信息");
    }

//

    @Autowired
    private IBlockexploreService iBlockexploreService;
    @Resource
    StringRedisTemplate stringRedisTemplate;

    //设定十分钟一次
    @Scheduled(fixedRate = 1000*60*10)
    public void updateredis() throws CertificateException, IOException, InvalidKeyException {

         iBlockexploreService.queryBlock();



        iBlockexploreService.updateBlockstore();

    }





}
